package net.kongliu.util.entity;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class SimpleValidationResult implements ValidationResult {
    private boolean hasErrors = false;
    private final List<ObjectError> errors = new LinkedList<>();

    @Override
    public boolean hasErrors() {
        return hasErrors;
    }

    @Override
    public List<ObjectError> getAllErrors() {
        return Collections.unmodifiableList(errors);
    }

    public void addError(ObjectError error) {
        errors.add(error);
    }

    public void setHasErrors(boolean hasErrors) {
        this.hasErrors = hasErrors;
    }
}
